<script setup lang='tsx' name='RecommendEvery'>
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue';
import { toCurrRem } from '@/utils/rem'
import { CalendarClearOutline, Play } from '@vicons/ionicons5'
//@ts-ignore
import bg from '@/assets/imgs/sky.png'
type Props = {
    title: string
}
const sheetItemRef = ref<null | HTMLElement>(null)
withDefaults(defineProps<Props>(), {})
function useWeek() {
    const date = new Date()
    return date.getDay()
}
onMounted(() => {
    resizeH()
    window.addEventListener('resize', resizeH)
})
function resizeH() {
    sheetItemRef.value.style.height = sheetItemRef.value.offsetWidth + 'px'
}
onUnmounted(() => {
    window.removeEventListener('resize', resizeH)
})
</script>

<template>
    <div class='song-sheet-item'>
        <div ref="sheetItemRef" class='song-sheet-item-img cursor-pointer'>
            <p class="tips">根据您的音乐口味生成每日更新</p>
            <img ref="imgRef" class="song-img" :src="bg" alt="">
            <div class="date-icon">
                <n-icon size="140" :component="CalendarClearOutline" color="#fff" />
                <span class="date">{{ useWeek() }}</span>
            </div>
            <div class="play-icon">
                <n-icon size="20" :component="Play" color="#ec4141" />
            </div>
        </div>
        <p class="song-title cursor-pointer">{{ title }}</p>
    </div>
</template>

<style lang='scss' scoped>
.song-sheet-item {

    .song-sheet-item-img {
        margin-bottom: 6px;
        position: relative;
        overflow: hidden;
        border-radius: 8px;
        box-shadow: inset 0px 0px 10px 20px #25305e;
        width: 100%;
        height: auto;

        &:hover .tips {
            top: 0%
        }

        .tips {
            background-color: rgba(0, 0, 0, .5);
            font-size: 18px;
            line-height: 30px;
            color: #fff;
            position: absolute;
            top: -100%;
            width: 100%;
            padding: 4px 8px;
            z-index: 1;
            transition: .4s;
            transition-delay: .5s;
        }

        .song-img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 8px;
            filter: blur(10px);
            //
        }

        .date-icon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);

            .date {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -30%);
                font-size: 50px;
                color: #fff;
            }
        }

        &:hover {
            .play-icon {
                opacity: 1;
            }
        }

        .play-icon {
            position: absolute;
            right: 10px;
            bottom: 10px;
            background-color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 50%;
            width: 34px;
            height: 34px;
            opacity: 0;
            transition: .7s;

            .n-icon {
                transform: translateX(1px)
            }
        }
    }

    .song-title {
        @include text-ellipsis-multi(2);
        height: 40px;
        line-height: 20px;
        padding: 0 4px;
        width: 100%;
    }
}
</style>